﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;

namespace MMS
{
    public partial class Page_SelectMember : UIPage
    {
        public Page_SelectMember()
        {
            InitializeComponent();
        }
        db_mmsEntities conn = new db_mmsEntities();
        private void Page_SelectMember_Load(object sender, EventArgs e)
        {
            uiDataGridView3.SetRowHeight(30);
        }
        private void btn_Select_Click(object sender, EventArgs e)
        {
            string id = txt_MemNb.Text;
            string mename = txt_memNm.Text;
            string mephone = txt_MemPhone.Text;
            string IDnumber = txt_IDNb.Text;
            if (!(id != "" || IDnumber != "" || mename != "" || mephone != ""))
            {
                MessageBox.Show("至少填一项！");
                return;
            }
            var member = conn.tb_member.Where(r => r.memberID == id || r.memberName == mename || r.phone == mephone || r.IDNumber == IDnumber).ToList();
            foreach (var i in member)
            {
                string ctype = "";
                switch (i.type)
                {
                    case 0://白金卡
                        ctype = "白金卡";                       
                        break;
                    case 1://金卡
                        ctype = "金卡";
                        break;
                    case 2://银卡
                        ctype = "银卡";                        
                        break;  
                }
                string[] temp = new string[] { i.memberID, i.memberName, i.phone,ctype, i.sumGrade.ToString(), i.signTime.ToString(), i.isUse==1?"可用":"未激活" };
                uiDataGridView3.Rows.Add(temp);
            }
        }

        
    }
}
